﻿using System;

using Blog.Models;

namespace Blog.ViewData
{
    public abstract class ListViewDataBase : ViewDataBase
    {
        public int PostsPerPage
        {
            get;
            set;
        }

        public int CurrentPage
        {
            get;
            set;
        }

        public PostListItem[] Posts
        {
            get;
            set;
        }

        public int PostCount
        {
            get;
            set;
        }

        public int PageCount
        {
            get
            {
                if (PostCount == 0 || PostsPerPage == 0)
                {
                    return 1;
                }

                int result = PostCount / PostsPerPage;

                if (PostCount % PostsPerPage != 0)
                {
                    result++;
                }

                return result;
            }
        }
    }
}
